Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 0,
    list: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    wx.request({
      url: 'https://rjgs.sz81jk.com/api/VYwbangAPI.ashx',
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data: {
        "action": "getDistributorOrder",
        "userid": wx.getStorageSync('userid'),
        "status": '0'
      },
      dataType: "json",
      success: function(res) {
        console.log(res.data);
        that.setData({
          list: res.data
        })
      }
    })
  },
  //点击切换
  clickTab: function(e) {
    var that = this;
    var status = e.target.dataset.current;
    if (this.data.currentTab == status) {
      return;
    } else {
      this.setData({
        currentTab: status
      })
    }
    wx.request({
      url: 'https://rjgs.sz81jk.com/api/VYwbangAPI.ashx',
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data: {
        "action": "getDistributorOrder",
        "userid": wx.getStorageSync('userid'),
        "status": that.data.currentTab
      },
      dataType: "json",
      success: function(res) {
        that.setData({
          list: res.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})